package com.shop.front.controller.pay;

import com.alibaba.fastjson.JSON;
import com.shop.front.service.store.StoreOrderService;
import com.shop.front.vo.store.StoreOrderUserDetailVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author Administrator
 * @Date 2024/4/19 12:29
 * @Version 1.0
 */
@Controller
@RequestMapping(value = "/page", method = RequestMethod.GET)
public class WxPayPageController {

    @Autowired
    private StoreOrderService storeOrderService;


    @RequestMapping("/index")
    public String index(Model model, HttpServletRequest request) {
        String order = request.getParameter("order");
        model.addAttribute("order",order);
        return "html/index";
    }

    @RequestMapping("/wxpay")
    public String wxpay(Model model, HttpServletRequest request) {
//        String orderNo = request.getParameter("orderNo");
        String orderNo = String.valueOf(request.getSession().getAttribute("orderNo"));
        if (StringUtils.isNotEmpty(orderNo)){
            StoreOrderUserDetailVo orderUserDetailVo = storeOrderService.infoDetailByOrderNo(orderNo);
            model.addAttribute("order", JSON.toJSONString(orderUserDetailVo));
        }
        return "html/wxpay";
    }


}
